<template>
<div class="no-print">
  <a-card class="info" title="员工档案">
    <template slot="extra">
      <template v-if="model.auditStatus==0">
        <a-button
            class="ruleButton"
            :ghost="true"
            type="primary"
            icon="edit"
            @click="handleEdit(model)"
            :disabled="isDisabledAuth('erpEmployeeFile:edit')"
        />
        <a-divider type="vertical"/>
        <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(model.id)">
          <a-button type="primary" size="small" :disabled="isDisabledAuth('erpEmployeeFile:submit')">提交</a-button>
        </a-popconfirm>
      </template>
      <template v-if="model.auditStatus==1">
        <a-button type="primary" size="small" @click="handleAudit(model.id)"
                  :disabled="isDisabledAuth('erpEmployeeFile:audit')">审核
        </a-button>
      </template>
      <template v-if="model.auditStatus==2">
        <a-popconfirm title="确定反审吗?" @confirm="() => handleCounterTrial(model.id)">
          <a-button type="primary" size="small" :disabled="isDisabledAuth('erpEmployeeFile:counterTrial')">反审</a-button>
        </a-popconfirm>
      </template>
    </template>
    <a-row type="flex" justify="center">
      <a-col :span="24">
        <erp-employee-file-form ref="realForm" :disabled="true" normal></erp-employee-file-form>
      </a-col>
    </a-row>
    <erp-employee-file-modal ref="modalForm" @ok="modalFormOk"></erp-employee-file-modal>
    <audit-modal ref="auditModal" @ok="modalFormOk"></audit-modal>
  </a-card>
  <div style="text-align: center;margin-top: 15px;">
    <a-button v-print="'#printContent'" type="primary">打印</a-button>
  </div>

    <ErpEmployeeFileFormPrint
      id="printContent"
      class="print_style"
      :formData="model"
      :formDataHistory="formData"></ErpEmployeeFileFormPrint>
</div>
</template>

<script>

import { getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpEmployeeFileForm from './modules/ErpEmployeeFileForm'
import ErpEmployeeFileFormPrint from './modules/ErpEmployeeFileFormPrint'
import ErpEmployeeFileModal from './modules/ErpEmployeeFileModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'


export default {
  name: 'ErpEmployeeFileDetail',
  mixins: [JeecgListMixin, DisabledAuthFilterMixin],
  components: {
    ErpEmployeeFileForm,
    ErpEmployeeFileFormPrint,
    ErpEmployeeFileModal
  },
  data() {
    return {
      model: {},
      id: '',
      url: {
        queryById: '/api/erp/files/employee/erpEmployeeFile/queryById',
        delete: '/api/erp/files/employee/erpEmployeeFile/delete',
        submit: '/api/erp/files/employee/erpEmployeeFile/submit',
        revoke: '/api/erp/files/employee/erpEmployeeFile/revoke',
        counterTrial: '/api/erp/files/employee/erpEmployeeFile/counterTrial',
        audit: '/api/erp/files/employee/erpEmployeeFile/audit',
        overrule: '/api/erp/files/employee/erpEmployeeFile/overrule',
      },
      confirmLoading: false,
      iconStyle: { 'font-size': '20px' },
    }
  },
  created() {
  },
  watch: {
    $route(to, from) {
      this.loadData();
    },
  },
  mounted() {
  },
  methods: {
    loadData() {
      const id = this.$route.params.id;
      getAction(this.url.queryById, { id }).then((res) => {
        if (res.success) {
          const model = res.result
          this.$refs.realForm.edit(model);
          this.model = model;
        }
      })
    },
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';

.info {
  /deep/ .ant-card-head-title {
    flex: none;
    margin-right: 20px;
  }

  /deep/ .ant-card-extra {
    flex: 1;
    float: left;
  }
}
</style>
